package org.nokatag.tagjava;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;

public class TabConten extends BodyNokaTag{
	private static final long serialVersionUID = -722440576842999789L;
	private String type="iframes-on-demand";//ajax or iframe or html
	private String name="";
	private String id="a1"; 
	private String width=null; 
	
	public int doEndTag() throws JspException {
		 StringBuilder stringBuilder = new StringBuilder();
		 BodyContent body = this.getBodyContent();
         String     content = (body.getString()==null?" ":body.getString());
         body.clearBody();
         String nWidth = "*";
         if(width!=null){
        	 nWidth = LenFormat(width);
         }
         stringBuilder.append("tabbar.addTab(\""+id+"\",\""+name+"\",\""+nWidth+"\");");
         if(type.equals("html")){
        	 stringBuilder.append("tabbar.setContentHTML(\""+id+"\",\""+content+"\");");
		 }else{
        	 stringBuilder.append("tabbar.setHrefMode(\""+type+"\");");
        	 stringBuilder.append("tabbar.setContentHref(\""+id+"\",\""+content+"\");");
		 }
         try {
				pageContext.getOut().write(stringBuilder.toString());
			} catch (IOException e) {
				e.printStackTrace();
			}
         return SKIP_BODY;
	 }
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}




	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public String getWidth() {
		return width;
	}


	public void setWidth(String width) {
		this.width = width;
	}


}
